/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.manager.view;

import br.com.foxline.model.City;
import br.com.foxline.model.Corrector;
import br.com.foxline.model.SystemUser;
import br.com.foxline.model.Users;
import br.com.foxline.service.CityService;
import br.com.foxline.service.CorrectorService;
import br.com.foxline.service.SystemUserService;
import br.com.foxline.service.UserService;
import java.io.Serializable;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author luciano
 */
@ManagedBean
@ViewScoped
public class ManagerViewCorrector implements Serializable{
    
    private Corrector corrector;
    private City city;
    private Users user;
    @EJB
    private CorrectorService correctorService;
    @EJB
    private CityService cityService;
    @EJB
    private UserService userService;
    
    
    @PostConstruct
    public void init(){
        Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
        String correctorId = params.get("correctorId");
        this.corrector = correctorService.find(Long.valueOf(correctorId));
        
        if (this.corrector.getAddress() != null) {
            this.city = cityService.find(this.corrector.getAddress().getCity().getId());
        }
        
        this.user = new Users();
        if(this.corrector.getUser() != null){
            this.user = userService.find(this.corrector.getUser().getId());
        }
    }

    public City getCity() {
        return city;
    }

    public void setCity(City city) {
        this.city = city;
    }

    public Corrector getCorrector() {
        return corrector;
    }

    public void setCorrector(Corrector corrector) {
        this.corrector = corrector;
    }

    public Users getUser() {
        return user;
    }

    public void setUser(Users user) {
        this.user = user;
    }

    
    
}
